/**
 * options就是配置对象 config.blacklist
 */
module.exports = (options,app)=>{
    //ctx上下文 next下一个
    //如何获取请求头
   return async function(ctx,next){
      let userAgent = ctx.get('user-agent')||'';
      let isMatched = options.ua.some(ua=>ua.test(userAgent));
      if(isMatched){
        ctx.status = 403;
        ctx.body = '你无权访问此页面';
      }else{
        await next();  
      }
   }
}